//
//  WeatherCellCell.m
//  PSYWeiBo
//
//  Created by xiaotian on 16/3/17.
//  Copyright © 2016年 郑亚田. All rights reserved.
//

#import "WeatherCell.h"

@implementation WeatherCell

- (instancetype)init {
    self = [super init];
    if (self) {
        [self addAllWeather];
    }
    return self;
}

- (void)addAllWeather {
    NSInteger colCount = 5;
    CGFloat marginY = 5;
    CGFloat marginX = 10;
    for (int i = 0; i < 7; i ++) {
        NSInteger row = i / colCount;
        NSInteger col = i % colCount;
        CGFloat x = marginX + col * (marginX + (kScreenWidth - marginX * 6) / 5);
        CGFloat y = 5 + marginY + row * (marginY + (kScreenWidth-marginX*6)/5);
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(x, y, (kScreenWidth - marginX * 6) / 5, (kScreenWidth - marginX * 6) / 5);
        [btn setImage:[UIImage imageNamed:[NSString stringWithFormat:@"newweather%d-select",i+1]] forState:UIControlStateSelected];
        [btn setImage:[UIImage imageNamed:[NSString stringWithFormat:@"newweather%d",i+1]] forState:UIControlStateNormal];
        btn.tag = 100 + i;
        [self addSubview:btn];
    }
}

- (void)awakeFromNib {
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
